<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">
        <div class="rc-pannel rc-searchbox">
            <form class="layui-form " method="get">
                <div class="rc-flex-vertical-center rc-searchbox">
                    <div class="layui-inline ">
                        <label class="layui-form-label" style="width: 90px;">手机号/用户名</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="username_phone" placeholder="" value="<?php echo request()->get('username_phone', ''); ?>" autocomplete="off" class="layui-input">
                        </div>
                    </div>



                    <div class="layui-inline">
                        <div class="layui-form-label">
                            <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary"><i class="iconfont">&#xeafe;</i> 搜索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>


        <div class=" rc-pannel rc-margin-top-default">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>
                        <a href="/admin/Admin/add" class="layui-btn layui-btn-primary layui-btn-sm" id="install"><i class="iconfont">&#xe60e;</i> 添加管理员</a>

                    </div>
                </div>


            </div>

            <div class="rc-pannel-body layui-form rc-pagepadding ">
                <table class="layui-table">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col style="width: 240px;">

                    </colgroup>
                    <thead>
                        <tr>
                            <th>用户名</th>
                            <th>手机</th>
                            <th>角色 <i class="layui-icon layui-icon-question rc-tips rc-pointer" message="仅仅显示最大的角色"></i></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($admins as $admin) {
                        ?>
                            <tr>
                                <td><?php echo $admin->username ?></td>
                                <td><?php echo $admin->phone ?></td>
                                <td>
                                    <?php
                                    if ($admin->issuperadmin == 1) {
                                    ?>
                                        <span class="layui-badge ">站点超管</span>
                                        <?php
                                    } else {
                                        $roleids = explode(',', trim($admin->roleids, ','));
                                        foreach ($roleids as $roleid) {
                                            if (isset($roles[$roleid])) {
                                        ?>
                                                <span class="layui-badge layui-bg-blue"><?php echo $roles[$roleid]['title'] ?></span>
                                    <?php
                                            }
                                        }
                                    }

                                    ?>
                                </td>
                                <td class="rc-opbar">
                                    <?php
                                    if (!$admin->issuperadmin == 1) {
                                    ?>
                                        <a class="info" href="/admin/Admin/edit?id=<?php echo $admin->id ?>"><i class="iconfont">&#xe606;</i> 编辑</a>
                                        <a class="error delete" adminuid="<?php echo $admin->uid ?>"><i class="iconfont">&#xe607;</i> 删除 </a>
                                    <?php
                                    }
                                    ?>

                                </td>
                            </tr>
                        <?php
                        }
                        ?>

                    </tbody>
                </table>



            </div>

            <div class="rc-pannel-footer">
                <div class="pagebar" style="text-align: right;">
                    <?php echo paginator($admins->total(), 20); ?>
                </div>

            </div>


        </div>

    </div>
</div>
<script type='text/javascript'>
    layui.use(function() {

        var layer = layui.layer;
        $('.delete').click(function() {
            var uid = $(this).attr('adminuid');
            layer.confirm('确定要删除么？', {
                icon: 3
            }, function() {
                $.ajax({
                    url: '/admin/Admin/delete?uid=' + uid, //请求路径
                    type: "POST", //请求方式
                    success: function(data) {
                        if (data.code == 0) {
                            window.location.reload();
                        } else {
                            toastr_error(data.message);
                        }
                        layer.closeAll();
                    },
                    error: function() {
                        layer.closeAll();
                    },

                });


            }, function() {



            });
        });


    });
</script>